<div class="layui-form-item">
    <div class="layui-row">
        <div class="layui-col-xs7">
            <label class="layadmin-user-login-icon layui-icon layui-icon-vercode" for="LAY-user-login-vercode"></label>
            <input type="text" name="captcha" id="LAY-user-login-vercode" lay-verify="required" maxlength="6"
                placeholder="图形验证码" class="layui-input">
        </div>
        <div class="layui-col-xs5">
            <div style="margin-left: 10px;">
                <img src="{:url('auth/captcha')}" class="layadmin-user-login-codeimg" id="captchaImg">
            </div>
        </div>
    </div>
</div>


<script>
    layui.use(['form'], function () {
        $('#captchaImg').click(function () {
            refresh();
        })
    });
    function refresh() {
        $('#captchaImg').attr('src', '{:url("auth/captcha")}?' + img_name_random());
        refreshToken();
    }
    //图片后缀随机数
    function img_name_random() {
        var rand_one = parseInt(100 * Math.random());
        var rand_two = parseInt(100 * Math.random());
        return String(rand_one) + String(rand_two);
    }
    refresh();
</script>
